import request from '@/utils/request';

export interface passwordParamsType {
  mobile: string;
  psw: string;
  smsCode: string;
}

interface messageListType {
  targetId: string; //目标端id，如果是劳动监察传入0
  type: 'CONSTRUCTION_UNIT' | 'BANK' | 'OA_INSPECTION' | 'LABOUR_INSPECTION' | 'OWNER_INSPECTION';
  read?: boolean; //是否已读 是：true；否:false
  pageNo?: number;
  pageSize?: number;
  clientMesType?:number
}
/**
 * 获取消息列表
 * @param param 
 * @returns 
 */
export async function queryMessage(params: messageListType) {
  return request('/api/message/list', {
    method: 'GET',
    params
  });
}
/**
 * 查询子消息类型
 * @param param 
 * @returns 
 */
export async function listMessageClientSubType(params: any) {
  return request('/api/message/listMessageClientSubType', {
    method: 'GET',
    params
  });
}

/**
 * 消息已读
 * @param params 
 * @returns 
 */
export async function readMessage(params: { id: any }) {
  return request('/api/message/read', {
    method: 'POST',
    data: params,
    requestType: 'form'
  });
}

export async function queryCurrent(param: { type: 'cm' | 'bk' | 'ls' | 'gs' }): Promise<any> {
  let url: string = ''
  switch (param.type) {
    case 'cm':
      url = '/api/user/info'
      break;
    case 'bk':
      url = '/bank/user/info'
      break;
    case 'ls':
      url = '/oa/user/info'
      break;
    case 'gs':
      url = '/tp/user/info'
      break;
    default:
      break;
  }
  return request(url, {
    method: 'GET',
  });
}

export async function changePassword(params: passwordParamsType, type: 'cm' | 'bk' | 'ls' | 'gs') {
  let url: string = ''
  switch (type) {
    case 'cm':
      url = '/api/user/changePassword'
      break;
    case 'bk':
      url = '/bank/user/changePassword'
      break;
    case 'ls':
      url = '/oa/user/changePassword'
      break;
    case 'gs':
      url = '/tp/user/changePassword'
      break;
    default:
      break;
  }
  return request(url, {
    method: 'POST',
    data: params,
    requestType: 'form'
  })
}
/**
 * 获取我的企业列表，切换企业
 */
export async function currentCorpList() {
  return request('/api/corp/currentCorpList', {
    method: 'GET'
  });
}
/**
 * 切换我的企业
 */
export async function changeCorp(params: { corpId: string}) {
  return request('/api/corp/changeCurrentCorp', {
    method: 'POST',
    data: params,
    requestType: 'form'
  })
}
/**
 * 获取当前权限
 */
export async function getPerm() {
  return request('/corp/user/info', {
    method: 'GET'
  });
}

export async function userSignInfo() {
  return request('/api/user/userIdCardInfo', {
    method: 'GET'
  });
}

export async function userCompany() {
  return request('/api/corp/getMyCorp', {
    method: 'GET'
  });
}
//个人签名图片
export async function userPersonSignImg() {
  return request('/oa/user/personSignImg', {
    method: 'GET'
  });
}
